﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MyMoviesBrowserLibrary;
using System.Diagnostics;

namespace TVManager
{
    /// <summary>
    /// Interaction logic for WatchedSeasonsControl.xaml
    /// </summary>
    public partial class WatchedSeasonsControl : UserControl
    {
        private TVManagerBusinessLayer bl = new TVManagerBusinessLayer();
        public WatchedSeasonsControl()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(WatchedSeasonsControl_Loaded);
        }

        void WatchedSeasonsControl_Loaded(object sender, RoutedEventArgs e)
        {
            RefreshData();
        }

        void RefreshData()
        {
            List<Season> seasons = bl.GetWatchedSeasons();
            seasonListBox.ItemsSource = seasons;
        }

        private void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            TextBlock tb = sender as TextBlock;
            if(tb == null)
                return;
            Episode episode = tb.Tag as Episode;
            string url = string.Format(Settings.Default.EpisodeSearchString, episode.Series.SeriesName, episode.SeasonNumber, episode.EpisodeName, episode.EpisodeNumber);
            Process.Start(url);
        }
    }
}
